package com.lingnan.wanxiangxinxun.controller.admin;

import com.lingnan.wanxiangxinxun.entity.po.NewsCategory;
import com.lingnan.wanxiangxinxun.entity.vo.service.NewUserCount;
import com.lingnan.wanxiangxinxun.entity.vo.common.Result;
import com.lingnan.wanxiangxinxun.entity.vo.service.WorkbenchData2;
import com.lingnan.wanxiangxinxun.service.INewsCategoryService;
import com.lingnan.wanxiangxinxun.service.INewsService;
import com.lingnan.wanxiangxinxun.service.WorkBenchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/admin/workbench")
public class WorkbenchController {

    @Autowired
    private WorkBenchService workBenchService;
    @Autowired
    private INewsService iNewsService;
    @Autowired
    private INewsCategoryService newsCategoryService;


    // 获取卡片1的数据
    @GetMapping("/getCardBox1Data")
    public Result getCardBox1Data(){
        List<Map<String, Long>> res = workBenchService.getCardBox1Data();
        return Result.success(res);
    }


    //获取热搜榜的数据
    @GetMapping("/getHotSearchList")
    public Result getHotSearchList() {
        List<String> hotSearchList = iNewsService.getHotSearchList();
        return Result.success(hotSearchList);
    }


    //获取作者申请数、待审核新闻数、头条新闻id以及标题
    @GetMapping("/getData2")
    public Result getData2() {
        WorkbenchData2 data2 = workBenchService.getData2();
        return Result.success(data2);
    }


    //获取近7天新增用户数量
    @GetMapping("/getWeekUserCount")
    public Result getWeekUserCount() {
        List<NewUserCount> weekUserCount = workBenchService.getWeekUserCount();
        return Result.success(weekUserCount);
    }


    //获取近3天各类新闻浏览量
    @GetMapping("/getViewNumOfVariousNews")
    public Result getViewNumOfVariousNews() {
        Map<NewsCategory, Integer> mapVO = newsCategoryService.getViewNumOfVariousNews();
        return Result.success(mapVO);
    }


}
